const CompressionPlugin = require('compression-webpack-plugin')
const linkUrl = 'http://localhost:'
const linkUrlAll = 'https://localhost'
//const  linkUrlAll='https://192.0.11.206'
const linkUrlFlag = false
module.exports = {
  publicPath: '/',
  productionSourceMap: process.env.NODE_ENV !== 'production',
  transpileDependencies: [
    'sm-crypto', 'js-base64', 'common'
  ],
  chainWebpack: config => config.resolve.symlinks(false),
  configureWebpack: {
    resolve: {
      alias: {
        'assets': '@/assets',
        'api': '@/api',
        'libs': '@/libs',
        'module': '@/components',
        'views': '@/views',
        'src': '@/'
      }
    },
    plugins: [
      new CompressionPlugin({
        algorithm: 'gzip',
        test: /\.js$|\.html$\.css$/,
        filename: '[path].gz[query]',
        minRatio: 1,
        threshold: 10240,
        deleteOriginalAssets: false,
      })
    ],
  },
  lintOnSave: false,
  css: {
    loaderOptions: {
      less: {
        modifyVars: {
          'primary-color': '#419aff',
          'link-color': '#419aff',
          'border-radius-base': '2px',
          'border-color-base': '#d9d9d9',
          'text-disabled-color': '#9facbc',
          'box-shadow-base': '0 2px 8px transparent',
          'btn-primary-color': '#ffffff',
          'btn-primary-bg': '#419aff',
          'btn-default-bg': '#e2e3e7',
          'btn-default-color': '#464d5b',
          'btn-default-border': '#e2e3e7',
          'font-size-base': '15px',
          'heading-color': '#464d5b',
          'text-color': '#6d7581',
        },
        javascriptEnabled: true,
      }
    }
  },
  devServer: {
    proxy: {
      '/auth': {
        target: linkUrlFlag ? linkUrlAll : linkUrl + '9990', //ztw构建的虚拟机对应自己的接口
        //target: 'http://192.0.10.21:9001', //ztw构建的虚拟机对应自己的接口
        secure: false,
        ws: true,
        changeOrigin: true,
        pathRewrite: {
          '^/auth': '/auth'
        }
      },
      '/sysconf': {
        target: linkUrlFlag ? linkUrlAll : linkUrl + '9990', //ztw构建的虚拟机对应自己的接口
        secure: false,
        ws: true,
        changeOrigin: true,
        pathRewrite: {
          '^/sysconf': '/sysconf'
        }
      },
      '/sysstyle': {
        //target: linkUrl+'8003', //ztw构建的虚拟机对应自己的接口
        target: linkUrlFlag ? linkUrlAll : linkUrl + '9990',
        secure: false,
        ws: true,
        changeOrigin: true,
        pathRewrite: {
          '^/sysstyle': '/sysstyle'
        }
      },

      '/audit': {
        //target: linkUrl+'9000', //hff搭建的微服务
        target: linkUrlFlag ? linkUrlAll : linkUrl + '9990',
        secure: false,
        ws: true,
        changeOrigin: true,
        pathRewrite: {
          '^/audit': '/audit'
        }
      },
      '/lab': {
        //target: linkUrl+'8091', //hff搭建的微服务
        target: linkUrlFlag ? linkUrlAll : linkUrl + '9990',
        secure: false,
        ws: true,
        changeOrigin: true,
        pathRewrite: {
          '^/lab': '/lab'
        }
      },
    },
    //host: 'localhost',
    // 此处开启 https
    //https: false,
    //disableHostCheck: true,
    port: '8082',
    headers: {
      'Access-Control-Allow-Origin': '*',
    }
  }
}
